package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonPage;
import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.FeedbackRequest;
import com.ytjj.qmyx.admin.model.response.FeedbackResponse;
import com.ytjj.qmyx.admin.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 意见反馈
 */
@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    @Autowired
    private FeedbackService feedbackService;

    /**
     * 分页查询意见反馈
     * @param feedbackRequest
     * @return
     */
    @PostMapping("/list")
    @OperLog(operModule = "意见反馈模块", operDesc = "反馈列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult list(@RequestBody FeedbackRequest feedbackRequest) {
        CommonPage<FeedbackResponse> pageList = feedbackService.list(feedbackRequest);
        return CommonResult.success(pageList);
    }

    /**
     * 标志是否处理
     */
    @GetMapping("/updateStatus")
    @OperLog(operModule = "意见反馈模块", operDesc = "标志是否处理", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateStatus(@RequestParam Integer id){
        int count = feedbackService.updateStatus(id);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }
}
